package com.example.kugou.commons.hashmap;

import com.example.kugou.pojo.Album;
import com.example.kugou.pojo.Mv;
import com.example.kugou.pojo.Sing;

import java.util.HashMap;
import java.util.List;

public class MyHashMap<String> extends HashMap<String,Album> {

    /**
     * 使用HashMap中containsKey判断key是否已经存在
     * @param key
     * @param value
     * @return
     */
    @Override
    public Album put(String key, Album value) {
        Album oldAlbum = get(key);
        if (containsKey(key)) {
            List<Sing> sings = oldAlbum.getSings();
            sings.add((Sing)(value.getSings().toArray()[0]));
            oldAlbum.setSings(sings);
        }
        return super.put(key, oldAlbum);
    }
}